﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.IO;
using System.Text;
using iTextSharp.text.pdf;
using iTextSharp.text.pdf.parser;
using System.Text.RegularExpressions;
namespace OrderAggregator.InputFormats.Novoaltaisk
{
	/// <summary>
    /// Новоалтайск, ул. Октябрёнок 68
	/// </summary>
    public class NovoaltaiskFormat : Excel.BaseExcelFormat
	{
		/// <summary>
		/// Parse
		/// </summary>
		/// <param name="filePath"></param>
		/// <param name="getStream"></param>
		/// <returns></returns>
        public override BaseOrder Parse(string filePath, Func<System.IO.Stream> getStream)
        {
            if (!string.Equals(System.IO.Path.GetExtension(filePath), dotPDF, StringComparison.InvariantCultureIgnoreCase))
            {
                return null;
            }

            using (var reader = new PdfReader(Path.GetFullPath(filePath)))
            {

                string pdfText = string.Empty;
                for (int i = 1; i <= reader.NumberOfPages; i++)
                {
                    ITextExtractionStrategy itextextStrat = new iTextSharp.text.pdf.parser.SimpleTextExtractionStrategy();
                    String extractText = PdfTextExtractor.GetTextFromPage(reader, i, itextextStrat);
                    extractText = Encoding.UTF8.GetString(ASCIIEncoding.Convert(Encoding.Default, Encoding.UTF8, Encoding.Default.GetBytes(extractText)));
                    pdfText = pdfText + extractText;
                    reader.Close();
                }
        }



            return null;
        }
         
    }
}



